package com.mall.user.feign;

import com.mall.common.util.JsonResult;
import com.mall.user.common.DeleteRequest;
import com.mall.user.model.dto.address.AddressAddRequest;
import com.mall.user.model.dto.address.AddressUpdateRequest;
import com.mall.user.model.entity.Address;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 地址服务 Feign 客户端
 */
@FeignClient(name = "userAddress-api")
public interface AddressFeignClient {

    /**
     * 添加地址
     */
    @PostMapping("/add")
    JsonResult<Long> addAddress(@RequestBody AddressAddRequest addressAddRequest);

    /**
     * 更新地址
     */
    @PostMapping("/update")
    JsonResult<Boolean> updateAddress(@RequestBody AddressUpdateRequest addressUpdateRequest);

    /**
     * 删除地址
     */
    @PostMapping("/delete")
    JsonResult<Boolean> deleteAddress(@RequestBody DeleteRequest deleteRequest);

    /**
     * 获取用户地址列表
     */
    @PostMapping("/list")
    JsonResult<List<Address>> getUserAddresses(HttpServletRequest request);

    /**
     * 根据ID获取地址
     */
    @GetMapping("/get/{id}")
    JsonResult<Address> getAddressById(@PathVariable("id") Long id);

    /**
     * 获取默认地址
     */
    @GetMapping("/default")
    JsonResult<Address> getDefaultAddress();

    /**
     * 设置默认地址
     */
    @PostMapping("/default/{id}")
    JsonResult<Boolean> setDefaultAddress(@PathVariable("id") Long id);
}
